package com.villaday.idf.adapter3;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.atuan.datepickerlibrary.CalendarUtil;
import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.model3.HotelSimilyEntity;

import java.util.ArrayList;
import java.util.List;

public class FindHouseWindShopNearAdapter extends AbsRecyclerViewAdapter<HotelSimilyEntity.BodyBean.ListBean> {

    public FindHouseWindShopNearAdapter(Context context) {
        super(context, com.villaday.idf.R.layout.recycle_fhwsd_near);
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, HotelSimilyEntity.BodyBean.ListBean d, int position) {
//        LogUtil.jLog().e(d.getLevelName() + "   " + d.getCurrentPriceValue() + "   " + d.getImageURL());
        try {
            holder.bindTextView(R.id.tv_fn_title, d.getName())
                    .bindTextView(R.id.tv_fn_type, d.getLevelName())
                    .bindTextViewWithHtml(R.id.vw_fn_money_left, "&yen;")
                    .bindTextView(R.id.tv_fhwsd_money, d.getCurrentPriceValue() == null ? "暂无" : d.getCurrentPriceValue())
                    .bindSimpleDraweeView(R.id.sdv_near, d.getImageURL());

            TextView tvDistance = (TextView) holder.getView(R.id.tv_fn_distance);
            TextView tvLine = (TextView) holder.getView(R.id.tv_fn_distance);

            if (d.getDistance() != null && !d.getDistance().equals("0")) {
                String htmlStr = "相距 " + "<font color='#FEC24A'>" + d.getDistance() + "</font> km";
                tvDistance.setText(Html.fromHtml(htmlStr));
            } else {
                tvDistance.setVisibility(View.GONE);
                tvLine.setVisibility(View.GONE);
            }


            TextView tv1 = (TextView) holder.getView(R.id.tv_fn_label1);
            TextView tv2 = (TextView) holder.getView(R.id.tv_fn_label2);
            TextView tv3 = (TextView) holder.getView(R.id.tv_fn_label3);
            List<TextView> list = new ArrayList<>();
            list.add(tv1);
            list.add(tv2);
            list.add(tv3);
            List<String> tags = (List<String>) d.getTags();
            if (tags != null && tags.size() != 0) {
                for (int i = 0; i < tags.size(); i++) {
                    if (i < 3) {
                        list.get(i).setVisibility(View.VISIBLE);
                        list.get(i).setText(tags.get(i));
                    }
                }
            } else {
                tv1.setVisibility(View.INVISIBLE);
                tv2.setVisibility(View.INVISIBLE);
                tv3.setVisibility(View.INVISIBLE);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
